home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / FixMath.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  5.0 KB  |  178 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        FixMath.p
  3.  
  4.      Contains:    Fixed Math Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT FixMath;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __FIXMATH__}
  27. {$SETC __FIXMATH__ := 1}
  28.  
  29. {$I+}
  30. {$SETC FixMathIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36.  
  37.  
  38. {$PUSH}
  39. {$ALIGN MAC68K}
  40. {$LibExport+}
  41.  
  42.  
  43.  
  44.  
  45. CONST
  46.     fixed1                        = $00010000;
  47.     fract1                        = $40000000;
  48.     positiveInfinity            = $7FFFFFFF;
  49.     negativeInfinity            = $80000000;
  50.  
  51. {
  52.     FixRatio, FixMul, and FixRound were previously in ToolUtils.h
  53. }
  54. FUNCTION FixRatio(numer: INTEGER; denom: INTEGER): Fixed;
  55.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  56.     INLINE $A869;
  57.     {$ENDC}
  58. FUNCTION FixMul(a: Fixed; b: Fixed): Fixed;
  59.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  60.     INLINE $A868;
  61.     {$ENDC}
  62. FUNCTION FixRound(x: Fixed): INTEGER;
  63.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  64.     INLINE $A86C;
  65.     {$ENDC}
  66.  
  67. FUNCTION Fix2Frac(x: Fixed): Fract;
  68.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  69.     INLINE $A841;
  70.     {$ENDC}
  71. FUNCTION Fix2Long(x: Fixed): LONGINT;
  72.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  73.     INLINE $A840;
  74.     {$ENDC}
  75. FUNCTION Long2Fix(x: LONGINT): Fixed;
  76.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  77.     INLINE $A83F;
  78.     {$ENDC}
  79. FUNCTION Frac2Fix(x: Fract): Fixed;
  80.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  81.     INLINE $A842;
  82.     {$ENDC}
  83. FUNCTION FracMul(x: Fract; y: Fract): Fract;
  84.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  85.     INLINE $A84A;
  86.     {$ENDC}
  87. FUNCTION FixDiv(x: Fixed; y: Fixed): Fixed;
  88.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  89.     INLINE $A84D;
  90.     {$ENDC}
  91. FUNCTION FracDiv(x: Fract; y: Fract): Fract;
  92.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  93.     INLINE $A84B;
  94.     {$ENDC}
  95. FUNCTION FracSqrt(x: Fract): Fract;
  96.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  97.     INLINE $A849;
  98.     {$ENDC}
  99. FUNCTION FracSin(x: Fixed): Fract;
  100.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  101.     INLINE $A848;
  102.     {$ENDC}
  103. FUNCTION FracCos(x: Fixed): Fract;
  104.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  105.     INLINE $A847;
  106.     {$ENDC}
  107. FUNCTION FixATan2(x: LONGINT; y: LONGINT): Fixed;
  108.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  109.     INLINE $A818;
  110.     {$ENDC}
  111. {
  112.     Frac2X, Fix2X, X2Fix, and X2Frac translate to and from
  113.     the floating point type "extended" (that's what the X is for).
  114.     On the original Mac this was 80-bits and the functions could be
  115.     accessed via A-Traps.  When the 68881 co-processor was added,
  116.     it used 96-bit floating point types, so the A-Traps could not 
  117.     be used.  When PowerPC was added, it used 64-bit floating point
  118.     types, so yet another prototype was added.
  119. }
  120. {$IFC TARGET_CPU_68K }
  121. {$IFC TARGET_RT_MAC_68881 }
  122. FUNCTION Frac2X(x: Fract): extended;
  123. FUNCTION Fix2X(x: Fixed): extended;
  124. FUNCTION X2Fix(x: extended): Fixed;
  125. FUNCTION X2Frac(x: extended): Fract;
  126. {$ELSEC}
  127. FUNCTION Frac2X(x: Fract): extended;
  128.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  129.     INLINE $A845;
  130.     {$ENDC}
  131. FUNCTION Fix2X(x: Fixed): extended;
  132.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  133.     INLINE $A843;
  134.     {$ENDC}
  135. FUNCTION X2Fix(x: extended): Fixed;
  136.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  137.     INLINE $A844;
  138.     {$ENDC}
  139. FUNCTION X2Frac(x: extended): Fract;
  140.     {$IFC TARGET_OS_MAC AND TARGET_CPU_68K AND NOT TARGET_RT_MAC_CFM}
  141.     INLINE $A846;
  142.     {$ENDC}
  143. {$ENDC}
  144. {$ELSEC}
  145. FUNCTION Frac2X(x: Fract): Double;
  146. FUNCTION Fix2X(x: Fixed): Double;
  147. FUNCTION X2Fix(x: Double): Fixed;
  148. FUNCTION X2Frac(x: Double): Fract;
  149. {$ENDC}  {TARGET_CPU_68K}
  150.  
  151. {  QuickTime 3.0 makes these Wide routines available on other platforms }
  152. {$IFC TARGET_CPU_PPC OR NOT TARGET_OS_MAC }
  153. FUNCTION WideCompare({CONST}VAR target: wide; {CONST}VAR source: wide): INTEGER; C;
  154. FUNCTION WideAdd(VAR target: wide; {CONST}VAR source: wide): WidePtr; C;
  155. FUNCTION WideSubtract(VAR target: wide; {CONST}VAR source: wide): WidePtr; C;
  156. FUNCTION WideNegate(VAR target: wide): WidePtr; C;
  157. FUNCTION WideShift(VAR target: wide; shift: LONGINT): WidePtr; C;
  158. FUNCTION WideSquareRoot({CONST}VAR source: wide): UInt32; C;
  159. FUNCTION WideMultiply(multiplicand: LONGINT; multiplier: LONGINT; VAR target: wide): WidePtr; C;
  160. { returns the quotient }
  161. FUNCTION WideDivide({CONST}VAR dividend: wide; divisor: LONGINT; VAR remainder: LONGINT): LONGINT; C;
  162. { quotient replaces dividend }
  163. FUNCTION WideWideDivide(VAR dividend: wide; divisor: LONGINT; VAR remainder: LONGINT): WidePtr; C;
  164. FUNCTION WideBitShift(VAR src: wide; shift: LONGINT): WidePtr; C;
  165. {$ENDC}
  166.  
  167.  
  168. {$ALIGN RESET}
  169. {$POP}
  170.  
  171. {$SETC UsingIncludes := FixMathIncludes}
  172.  
  173. {$ENDC} {__FIXMATH__}
  174.  
  175. {$IFC NOT UsingIncludes}
  176.  END.
  177. {$ENDC}
  178.